package cn.tiansu.eway.datafile.manager;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;
import org.jfree.util.Log;

import cn.tiansu.eway.datafile.model.ChangeDataInfo;

/**
 * 数据处理类
 * 
 * @Title: Operator.java
 * @Description: TODO
 * @author: 吴鹏
 * @date: 2016年1月25日
 * 
 *
 */
public class Operator
{
	private static final Logger log = Logger.getLogger(Operator.class);

	
	public void deal(Map<String, Set<String>> map, ChangeDataInfo info)
	{
		String tenant = info.getTenant().toUpperCase();
		String time = info.getTime();
		
		log.info("################ map1="+map);

		Set<String> dateTimeSet = map.get(tenant);

		if (dateTimeSet == null)
		{
			dateTimeSet = new HashSet<String>();
			map.put(tenant, dateTimeSet);
		}

		log.info("################ map2="+map);
		
		if (time.length() < 10)
		{
			log.warn("time is illegal,time.length()="+time.length());
			return;
		}

		String dateTimeStr = time.substring(0, 10);

		if (!dateTimeSet.contains(dateTimeStr))
		{
			dateTimeSet.add(dateTimeStr);
		}
		
		log.info("################ map3="+map);
	}

	public static void main(String[] args)
	{
		Map<String, Set<String>> map = new HashMap<String, Set<String>>();
		ChangeDataInfo info = new ChangeDataInfo();
		info.setSensor("a");
		info.setTenant("newcity");
		info.setTime("2012-12-13");
		Operator o = new Operator();
		
		o.deal(map, info);
		System.out.println(map);
	}
}
